<?php

namespace Modules\Edu\Entities;

use App\Models\Traits\Favour;
use Illuminate\Database\Eloquent\Model;
use App\User as AppUser;

class User extends AppUser
{
//签到关联，一对多
    public function signs()
    {
        return $this->hasMany(Sign::class);
    }

//是否签到，判定当天是否有签到记录
    public function getIsSignAttribute()
    {

        return $this->signs()->day()->exists();
    }

//总签到
    public function getSignTotalAttribute()
    {
        return $this->signs()->count();
    }

//月签到
    public function getMonthSignAttribute()
    {
        return $this->signs()->month()->count();
    }

//签到
    public function getSignAttribute()
    {
        return $this->signs()->day()->first();
    }

    //用户的贴子
    public function topics()
    {
        return $this->hasMany(Topic::class);
    }

    public function studys(){
        return $this->belongsToMany(Video::class,'edu_study_path','user_id','video_id')->withTimestamps();
    }

}
